/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  if (nums.length > 1) {
    let curIndex = 0,
      tmpIndex = 0
    while (curIndex <= nums.length - 1) {
      const curVal = nums[curIndex]
      while (nums[tmpIndex + 1] == curVal) {
        tmpIndex++
      }
      nums.splice(curIndex + 1, tmpIndex - curIndex)
      curIndex++
      tmpIndex = curIndex
    }
  }

  return nums.length
};

removeDuplicates = function (nums) {
  if (nums.length > 1) {
    let curIndex = 0
    while (curIndex <= nums.length - 1) {
      let tmpIndex = curIndex
      const curVal = nums[curIndex]
      for (; nums[tmpIndex + 1] == curVal; tmpIndex++) {
      }
      nums.splice(curIndex + 1, tmpIndex - curIndex)
      curIndex++
    }
  }

  return nums.length
};
console.log(removeDuplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))